package com.hunttown.mes.rpc.domain.enums.sms;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 短信发送类型：1注册 2登录 3找回密码 4行程派单 5客户预订
 * created by wangjunfu on 2018/11/6
 */
public enum SmsTypeEnum {
    SMSSIGN(0, "短信签名"),
    REGISTER(1, "用户注册"),
    LOGIN(2, "用户登录"),
    FINDPWD(3, "找回密码"),
    DRIVERMSG(4, "行程派单"),
    USERMSG(5, "客户预订"),
    LIFE(6, "帐户消费"),
    RECHARGE(7, "帐户充值"),
    BALANCE(8, "帐户余额"),
    POWEROFF(9, "设备分闸"),
    POWERON(10, "设备合闸"),
    ORTHER(29, "其它"),
    FORBID(30, "禁止使用");

    private final int key;
    private final String value;

    SmsTypeEnum(int key, String value) {
        this.key = key;
        this.value = value;
    }

    // 根据key获取枚举
    public static String getEnumByKey(int key) {
        String value = "";

        for (SmsTypeEnum temp : SmsTypeEnum.values()) {
            if (temp.getKey() == key) {
                value = temp.getValue();
            }
        }

        return value;
    }

    // 将枚举组成Map
    public static Map<Integer, String> getEnumList() {
        Map<Integer, String> map = new HashMap<>();

        for (SmsTypeEnum temp : SmsTypeEnum.values()) {
            map.put(temp.getKey(), temp.getValue());
        }

        return map;
    }

    // 将枚举组成Map（因为枚举是公用的，所以不同项目选择的不一样）
    public static Map<Integer, String> getEnumList(List<Integer> keys) {
        Map<Integer, String> map = new HashMap<>();

        for (SmsTypeEnum temp : SmsTypeEnum.values()) {
            if (keys.contains(temp.getKey())) {
                map.put(temp.getKey(), temp.getValue());
            }
        }

        return map;
    }

    public int getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }
}
